NAME=kafka-tool
VERSION=$(shell cat VERSION)

.PHONY: all build 

all: build 

build:
	@mkdir -p ./packet/${VERSION}
	@go build -o ./packet/${VERSION}/${NAME} main.go

x86:
	GOOS=linux GOARCH=amd64 go build -ldflags -v -o ./packet/amd64/${VERSION}/${NAME} main.go
	tar -zcvf ./packet/${VERSION}/${NAME}-${VERSION}.linux-amd64.tar.gz ./packet/amd64/${VERSION}/${NAME}

arm64:
	GOOS=linux GOARCH=arm64 GOARM=7 go build -ldflags -v -o ./packet/arm64/${VERSION}/${NAME} main.go
	tar -zcvf ./packet/${VERSION}/${NAME}-${VERSION}.linux-arm64.tar.gz ./packet/arm64/${VERSION}/${NAME}

run: build
	@chmod +x ./packet/${VERSION}/${NAME}
	./packet/${VERSION}/${NAME} -h
	
help:
	@echo "make 格式化go代码 并编译生成二进制文件"
	@echo "make build "
	@echo "make run "
